<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Archived_feedback extends CI_Controller {
	public function index()
	{
            $this->showMonth();
	}
        
        public function showMonth($year = null, $month = null){
            if ($year == null || $month == null){
                $year = date("Y");
                $month = date("m");
            }
            //If not the current month
            $prevDate = date("Y/n", mktime(0,0,0,$month-1,1,$year));
            $nextDate = date("Y/n", mktime(0,0,0,$month+1,1,$year));
            
            $this->load->model('feedbacks');
            $feedback = $this->feedbacks->getArchived($year,$month);
            
            $data['title'] = "Archived Feedback";
            
            $data['data'] = array (
                "feedback" => $feedback,
                "current_year" => $year,
                "current_month" => $month,
                "prevDate" => $prevDate,
                "nextDate" => $nextDate
                );
            
            $data['js'] = array("feedback.js");
            $data['css'] = array("table.css", "datepicker/datepicker.min.css");
            $data['view'] = "feedback/view_archived_feedback";
            $this->load->view('view_template',$data);
        }
        
        public function viewFeedback(){
//            extract($this->ajax->post("feedback_id"));
            $feedback_id = $this->input->get("feedback_id");
            $this->load->model('feedbacks');
            
            $feedback = $this->feedbacks->getFeedbackWithResponse($feedback_id);
            
            $this->load->view('ajax/view_feedback_full',array('feedback'=>$feedback));
        }
}